package com.longge;

public class FindPoisonedDuration {

    public int findPoisonedDuration(int[] timeSeries, int duration) {

        int ans = 0, time = 0;
        for (int timeSery : timeSeries) {
            if (time < timeSery) {
                ans += duration;
            } else {
                ans += duration - (time - timeSery);
            }
            time = timeSery + duration;
        }
        return ans;
    }

}
